package com.example.service.impl;

import com.example.mapper.TeacherMapper;
import com.example.pojo.ParseStudent;
import com.example.pojo.ParseTeacher;
import com.example.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Vector;

@Service
public class TeacherServiceimpl implements TeacherService {
    @Autowired
    TeacherMapper teacherMapper;
    @Override
    public Vector<ParseTeacher> select() {
        Vector<ParseTeacher> parseTeachers=teacherMapper.select();
        return  parseTeachers;
    }

    @Override
    public Vector<ParseTeacher> selectTeacher(String name, String department,String id) {
        Vector<ParseTeacher> parseTeachers= teacherMapper.selectTeacher(name,department,id);
        return parseTeachers;
    }

    @Override
    public void update(ParseTeacher parseTeacher) {
        teacherMapper.update(parseTeacher);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void delete(String name) {
        teacherMapper.delete_1(name);
        teacherMapper.delete_2(name);
    }

    @Override
    public void addTeacher(ParseTeacher teacher) {
        teacherMapper.insertTeacher(teacher);
        teacherMapper.insertPass(teacher);
    }

    @Override
    public ArrayList<String> selectTeachers() {
        ArrayList<String> parseTeachers=teacherMapper.selectTeachers();
        return  parseTeachers;
    }
}
